#include <iostream>
#include <unistd.h>
#include <signal.h>

void PrintBlock()
{
    sigset_t set, oset;
    ::sigemptyset(&set);
    ::sigemptyset(&oset);
    ::sigprocmask(SIG_BLOCK, &set, &oset);

    for(int signo = 31; signo >= 1; signo--)
    {
        if (sigismember(&oset, signo))
        {
            std::cout << "1";
        }
        else
        {
            std::cout << "0";
        }
    }
    std::cout << std::endl;
}
void handler(int signo)
{
    static int cnt = 0;
    cnt++;
    while(true)
    {
        std::cout << "get a sig: " << signo << ", cnt: " << cnt << std::endl;
        sleep(1);
    }
    exit(0);
}
int main()
{
    struct sigaction act, oact;
    act.sa_handler=handler;

    ::sigaction(SIGINT, &act, &oact);
    while(true)
    {
        pause();
    }
}